<?php

namespace App\Console\Commands;

use App\Console\AdminMakerCommand;
use Artisan;

class MakeAdminModel extends AdminMakerCommand
{
    protected $type = 'admin模型';

    protected $namespacePrefix = 'Models';

    protected $stubPath = __DIR__.'/stubs/model.stub';

    protected $signature = 'admin:make-model {name}';

    protected $description = '生成一个后台所需的模型文件';

    public function handle()
    {
        parent::handle();

        $table = str_plural($this->getNameInput());
        $this->call('make:migration', [
            'name'     => "create_{$table}_table",
            '--create' => $table,
        ]);
    }

    protected function qualifyClass($name)
    {
        $modelName = parent::qualifyClass($name);

        $modelName = "{$this->namespacePrefix}\\{$modelName}";

        return $modelName;
    }
}
